<div class="row">
	<div class="col-sm-12">
	
<form action="<?php echo DOMAIN_NURSERY?>/role/edit" method="post"  id='add_user_submit'>
	<input type="hidden" name="id" value="<?php echo $role_id; ?>" id="data-role-edit-id">
		<table id="inputs-table" class="table table-striped table-bordered table-hover" >
			<tr>

				<td width="100" align="right"><nobr>
						<strong class="red">*</strong> 角色名称:
					</nobr></td>
				<td>
					<input type="text" name="name"  id="data-role-name"
						   value="<?php echo $name;?>" style="width: 30%" maxlength="20" >
					<label class="red" id="data-role-name-error"><?php echo form_error('name')?></label>
				</td>
			</tr>

			
			<tr>
				<td colspan="2" align="center">
					<button class="btn btn-info btn-sm" type="submit">提交</button>
				</td>
			</tr>
		</table>
</form>

</div>
</div>


<script type="text/javascript">

	$(document).on('keyup', '#data-role-name', function () {

		var role_name=$('#data-role-name').val();
		var role_id=$('#data-role-edit-id').val();
		var url='<?php echo DOMAIN_MAIN?>/api/npermissions/check_role_name';
		var params={
			role_name:role_name,
			role_id:role_id
		};

		$.get(url, params, function (data) {
			if(data.state=='success'){
				var new_dom='角色名称已存在，请重新填写！';
				$("#data-role-name-error").html(new_dom);
				return false;
			}else{
				$("#data-role-name-error").html('');
				return true;
			}

		},'json');

	});
</script>
